package com.example.androidtest3

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class SecondActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_second)
        val intent=getIntent()//获取得到主页面的意图
        val textView=findViewById<TextView>(R.id.textView)
        textView.text=intent.getStringExtra(FIRST_MSG)//传入参数对应的那个键就会得到对应键的值
        val button=findViewById<Button>(R.id.button)
        button.setOnClickListener {
           finish()//不能重新在创建意图然后再打开主页面这样会一直在增加页面没有具体实现关闭返回到最初的页面
        }
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }
}